﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NerdDinner.Web.Models.Data;
using NerdDinner.Web.Models.Validation;

namespace NerdDinner.Web.Helpers
{
    public static class ModelStateHelpers 
    { 
        public static void AddRuleViolations(this ModelStateDictionary modelState, IEnumerable<RuleViolation> errors) 
        { 
            foreach (RuleViolation issue in errors) 
            { 
                modelState.AddModelError(issue.PropertyName, issue.ErrorMessage); 
            } 
        } 
    } 
}
